package com.ep.general.app;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.Logger;

public class Utils {

	protected static final Logger logger = Logger.getLogger("GeneralUtils");

	public static String convertToMd5(String input) {
		MessageDigest md = null;
		try {
			md = MessageDigest.getInstance("MD5");
			md.update(input.getBytes(), 0, input.length());

		} catch (NoSuchAlgorithmException e) {
			logger.error("Nieprawidłowy algorytm konwersji");
		}
		return new BigInteger(1, md.digest()).toString(16);
	}

	public static String convertDMY(Date data) {
		SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
		return sdf.format(data);
	}
}
